<%--
 *  File:    ApprovalUserSummary.jsp
 *  @Author: Saraxia 
 *  Date:    2012/11/09
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval. 
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>      
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.ApprovalUserSummary"); 
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "PCM";
  	String strTableName = "";
  	String privilegeCode = "Z0104";
  	String contextPath = request.getContextPath();
%>



<%
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	String isPrimaryAdmin = (String)CurUserInfo.get("isprimaryadmin");
  	Integer nCurUserId = (Integer)CurUserInfo.get("zylmdapprovaluserid");
  	if(isPrimaryAdmin == null)
  	{
    	isPrimaryAdmin = "";
  	}
  	
  	//Integer zylmdapprovaltype = (Integer)pageContext.getAttribute("zylmdapprovaltype");
  	
  
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>ApprovalUserSummary</title>
<PageFlow:CheckPageFlow pageName="approvalusersummary"/>
<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector userGroupSummary = (Vector)pageContext.getAttribute("ugsummary");
  	if(userGroupSummary == null)
  	{
    	userGroupSummary = new Vector();
  	}
  	
  	
%>
<%@ include file="/inc/InitEdit.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script>


function page_add(){
	//if(!checkSalesQty()) return;
	 //if(!checkForm(cform)) return;
	  if(!checkForm(document.usergroupsummaryform)) return;
	 usergroupsummaryform.actionname.value = "add";
	 usergroupsummaryform.target = "_self";
  	 isRunning = true;
  	 usergroupsummaryform.submit();
}

function page_delete(){
   

    var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
    if(!flag)
      return;
    document.usergroupsummaryform.actionname.value = "delete";
    isRunning = true;
    document.usergroupsummaryform.submit();
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(usergroupsummaryform,actionvalue,orderbyname);
  //var zylmdapprovaltype= document.usergroupsummaryform.userinformation.value;
  //alert(zylmdapprovaltype);
  editform.action = "ApprovalUserSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}



var popwindow;
function popUsergroup(){
	if(popwindow!=null) popwindow.close();	
    //url = 'ApprovalUserGroupForPop.jsp?flag=1&zylmdapprovalgroupid='+zylmdapprovalgroupid+'&<%= OvalTools.randomURL() %>';
    url = 'ApprovalUserGroupForPop.jsp?flag=1<%= OvalTools.randomURL() %>';
    attribute = 'height=300, width=700,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';
	popwindow = window.open(url,'newwindow', attribute);
}


function setContact(id,mdapprovalgroupname,isjoint){
	document.usergroupsummaryform.zylmdapprovalgroupid.value=id;
	document.usergroupsummaryform.mdapprovalgroupname.value=mdapprovalgroupname;
	//document.usergroupsummaryform.isjoint.value=isjoint;
	if(isjoint==1){
		document.usergroupsummaryform.isjoint.value='是'
		}
	else{
		document.usergroupsummaryform.isjoint.value='否'
		}
}

</script>


</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

	<% //--------------------------------------  hidden form variant --%>
	<form name="usergroupsummaryform" method="post" action="../../Dispatcher"  target="_self">
    <input type="hidden" name="pagename" value="approvalusersummary">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">

    
	<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
  	<tr> 
    	<td valign="top"> 
    		<table width="100%" border="0" cellspacing="0">
          	<tr><td class="summary_top" ></td></tr>
        	</table>
			<table width="20%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td><%= label.getLabelName("L_Type1") + label.getLabelName("L_Colon") %></td>
					<td><custom:selectdic property="zylmdapprovaltype"
						dictType="ZylMdApprovalType"  defaultValueCost="" onchange="page_summary('search')"/>
					</td>
					<!-- 
					<td><a href="javascript:page_summary('search')"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
					 -->
				</tr>
        	</table>
        </td>
   	</tr>
   	</table>
   
   	<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="0">
   
   	<% //--------------------------------------  summary header --%>
   	<tr bgcolor="#ACBCCA"  class="deepblue-left" > 
   		<td width="5%"  class="title_center" >&nbsp;</td>
       	<td width="30%" class="title_center" ><a href="javascript:page_summary('orderby','approvalno')"><%= label.getLabelName("L_Num") %></a></td>
       	<td width="30%" class="title_center" ><a href="javascript:page_summary('orderby','mdapprovalgroupname')"><%= label.getLabelName("L_UserGroup") %></a></td>
       	<td width="30%" class="title_center" ><a href="javascript:page_summary('orderby','isjoint')"><%= label.getLabelName("L_YorNExaApproval") %></a></td>
    </tr>

	<% //--------------------------------------  default value definition --%>
    <%
        Integer nDefaultzylmdapprovalgroupid = new Integer(-1);               
        String strClassType = new String(); 
        boolean bHasChecked = false;
        String strDefaultIsDisabled="";
        String strDefaultmdapprovalgroupname=""; 
   	%>
   	
    <% //--------------------------------------  loop results --%>
    <logic:iterate id="usergroup" collection="<%= userGroupSummary %>" indexId="orderId">                      
    	
    <%
    	HashMap userGroupMap = (HashMap)pageContext.getAttribute("usergroup"); 
        //String ugName = (String)userGroupMap.get("mdapprovalgroupname");
        String strIsDisabled = "";
        String strIsChecked = "";
            
        if((orderId.intValue())%2 == 1){
        	strClassType = "td-listrom";             
        }else{                    
            strClassType = "none";
        }

        if(!bHasChecked)
        {
	        strIsChecked = "Checked";                       
            bHasChecked = true;
            nDefaultzylmdapprovalgroupid = (Integer)(userGroupMap.get("zylmdapprovaluserid"));
            strDefaultmdapprovalgroupname= (String)(userGroupMap.get("mdapprovalgroupname"));    
          	strDefaultIsDisabled = strIsDisabled;            
        }                
  	%>
    
    <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" <%if(strIsDisabled.length()==0){%> onClick="javascript:radiotrue0('usergroup<%=JspHelper.filterNull( orderId )%>');"<%}%> class="<%=JspHelper.filterNull( strClassType )%>">
    	<td class="<%=JspHelper.filterNull( strClassType )%>">
        	<input id="usergroup<%=JspHelper.filterNull( orderId )%>" type="radio" name="zylmdapprovalgroupids" <%=JspHelper.filterNull( strIsDisabled )%> value=<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovaluserid") )%> class="normalradio" <%=JspHelper.filterNull( strIsChecked)%> <%if(strIsDisabled.length()==0){%> onClick="javascript:clickUserGroup('<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovaluserid") )%>')"<%}%>>
        </td>
        <td class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userGroupMap.get("approvalno") )%></td>
        <td class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userGroupMap.get("mdapprovalgroupname") )%></td>
        <td class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<custom:write property="isjoint"  dictType="YesOrNo" nbsp="true" name="usergroup"  /></td>
    </tr>
    </logic:iterate>  
    <input type="hidden" name="zylid" value="<%=JspHelper.filterNull( nDefaultzylmdapprovalgroupid )%>">
    
     <tr>
    	<td>&nbsp;</td>
    	<td>&nbsp;</td> 
       	<td> 
			<custom:hidden name="onerow" property="zylmdapprovalgroupid"/>
			<custom:text name="onerow" property="mdapprovalgroupname" readonly="true" size="30" command="notnull" label="L_UserGroup"/>
			<a onclick="popUsergroup()"><custom:button type="3" value="*"/></a> <span class="red" size="1">*</span>
        </td>                  
       	<td ><custom:text name="onerow" property="isjoint" readonly="true" size="30" style="border:0;"/>
       	<!-- 
       	<custom:selectdic property="isjoint" dictType="YesOrNo" defaultValueCost="" defaultValue="----"/>
       	<custom:text name="onerow" property="isjoint" readonly="true" size="30"/>
       	<input type="hidden" name="zylmdapprovaluserid" value="<%=JspHelper.filterNull( nDefaultzylmdapprovalgroupid )%>">
       	<custom:text property="approvalno"></custom:text>
       	<custom:write property="isjoint"  dictType="YesOrNo" nbsp="true" name="usergroup"  />
       	 -->
     </tr> 
      
          
    <% //--------------------------------------  flipping page --%>
    <%@ include file="/inc/SummaryAction.inc" %>
    </table>
    
    <% //--------------------------------------  page operation button --%>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    	<tr> 
        	<td class="summary_top" ></td>
        </tr>
		<%if(privilegeSet != null && privilegeSet.contains("B6040")){%>  
        <tr> 
        	<td class="td_center"> 
				<a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="new.gif" border="0" style="width:60"/></a>	
        		<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>        		
        	</td>
        </tr>
		<% } %>
  	</table>

   	</td>
</tr>
</table>
</form>
</body>
</html>


